﻿#if UNITY_EDITOR
using System.Collections.Generic;
using System.Xml.Serialization;
using Unity.Collections;
/// <summary>
/// Xlsx表自动生成目录架构
/// </summary>
[XmlRoot("ESF_Xml_XlsxAutoBuildFolder")]
public class ESF_Xml_XlsxAutoBuildFolder: AbsESF_Xml
{
    /// <summary>
    /// 脚本构架解析Xlsx表目录
    /// </summary>
    [XmlElement("脚本构架解析Xlsx表目录")]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxSchemaResolveFolder;

    /// <summary>
    /// Xlsx表缺省语言数据
    /// </summary>
    [XmlElement("Xlsx表缺省语言数据")]
    [ReadOnly()]
    public enESF_AllLanguageClassify xlsxDefaultTableLanguage;

    /// <summary>
    /// Helper脚本类名
    /// </summary>
    [XmlElement("Helper脚本类名")]
    [ReadOnly()]
    public string xlsxScriptHelperClassName;

    /// <summary>
    /// GetKey方法名称
    /// </summary>
    [XmlElement("GetKey方法名称")]
    [ReadOnly()]
    public string getKeyMethodName;

    /// <summary>
    /// VerifyKey方法名称
    /// </summary>
    [XmlElement("VerifyKey方法名称")]
    [ReadOnly()]
    public string verifyKeyMethodName;

    /// <summary>
    /// LogError方法名称
    /// </summary>
    [XmlElement("LogError方法名称")]
    [ReadOnly()]
    public string logErrorMethod;

    /// <summary>
    /// tableRow变量名称
    /// </summary>
    [XmlElement("tableRow变量名称")]
    [ReadOnly()]
    public string tableRowVarName;

    /// <summary>
    /// tableRow的data变量名称
    /// </summary>
    [XmlElement("tableRow的data变量名称")]
    [ReadOnly()]
    public string tableRowDataVarName;

    /// <summary>
    /// Helper脚本Sizeof文件路径
    /// </summary>
    [XmlElement("Helper脚本Sizeof文件路径")]
    [ReadOnly()]
    public string xlsxScriptHelperSizeofFilePath;

    /// <summary>
    /// Helper脚本Select文件路径
    /// </summary>
    [XmlElement("Helper脚本Select文件路径")]
    [ReadOnly()]
    public string xlsxScriptHelperSelectFilePath;

    /// <summary>
    /// xlsx脚本根目录
    /// </summary>
    [XmlElement("xlsx脚本根目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxScriptRootFolder;

    /// <summary>
    /// Helper脚本目录
    /// </summary>
    [XmlElement("Helper脚本目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxScriptHelperFolder;

    /// <summary>
    /// 实体脚本目录
    /// </summary>
    [XmlElement("实体脚本目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxScriptEntityFolder;

    /// <summary>
    /// 扩展脚本目录
    /// </summary>
    [XmlElement("扩展脚本目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxScriptExtendFolder;

    /// <summary>
    /// 数据库源Xlsx表目录
    /// </summary>
    [XmlElement("数据库源Xlsx表目录")]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxDbLibaray_SourceFolder;

    /// <summary>
    /// 数据库目标目录
    /// </summary>
    [XmlElement("数据库目标目录")]
    [ESF_GUIOperation()]
    [ESF_PathSelect(enESF_PathSelectCatalogClassify.InternalAssets, enESF_PathSelectAssetClassify.Folder)]
    public string xlsxDbLibaray_TargetFolder;

    /// <summary>
    /// XlsxDbLibrary文件路径
    /// </summary>
    [XmlElement("XlsxDbLibrary文件路径")]
    [ESF_GUIBrower()]
    [ReadOnly()]
    public string xlsxDbLibraryFilePath;

    /// <summary>
    /// 语言包设置
    /// </summary>
    [XmlElement("语言包设置")]
    [ReadOnly()]
    [ESF_ArrayMaxLength(typeof(enESF_LanguageClassify))]
    public ESF_Xml_XlsxAutoBuildFolder_LangItem[] langs;

    [XmlElement("自动忽略字段的类型")]
    [ReadOnly()]
    public string autoIgnoreTypeName;
    
    /// <summary>
    /// 解析
    /// </summary>
    protected override void OnResolve()
    {
        logErrorMethod = "//Log.Error";
        getKeyMethodName = "GetKey";
        verifyKeyMethodName = "VerifyKey";
        tableRowVarName = "mRow";
        tableRowDataVarName = "data";
        xlsxScriptHelperClassName = "HFDbHelper";
        autoIgnoreTypeName = "ignore";
        xlsxDefaultTableLanguage = ESF_Logic.languageSetting.xml.defaultAlternateLanguage;
        List<ESF_Xml_XlsxAutoBuildFolder_LangItem> result = new List<ESF_Xml_XlsxAutoBuildFolder_LangItem>();
        ESF_Xml_LanguageSetting_Item[] items = ESF_Logic.languageSetting.xml.supportLangs;
        if (items != null && items.Length > 0)
        {
            foreach (ESF_Xml_LanguageSetting_Item key in items)
            {
                ESF_Xml_XlsxAutoBuildFolder_LangItem t = new ESF_Xml_XlsxAutoBuildFolder_LangItem();
                t.classify = key.classify;
                t.xlsxTable_SrcFolder = xlsxDbLibaray_SourceFolder.ESF_CombinePath(key.classify.ESF_FirstAttribute<ESF_FolderNameAttribute>().folderName).ESF_TransPathSeparatorCharToUnityChar();
                t.dbTable_TargetFolder = xlsxDbLibaray_TargetFolder.ESF_CombinePath(key.classify.ESF_FirstAttribute<ESF_FolderNameAttribute>().folderName).ESF_TransPathSeparatorCharToUnityChar();
                result.Add(t);
            }
        }
        langs = result.ToArray();

        ESF_BuildEngineAsset bea = new ESF_BuildEngineAsset(typeof(XlsxDbLibrary).Name, xlsxDbLibaray_TargetFolder, enESF_UnityFileExt.Asset, typeof(XlsxDbLibrary).FullName);
        xlsxDbLibraryFilePath = bea.filePath;

        ESF_BuildTextAsset bta = new ESF_BuildTextAsset("", xlsxScriptRootFolder, enESF_UnityFileExt.CS, "");
        bta.SetFileName($"{xlsxScriptHelperClassName}_SizeOf");
        xlsxScriptHelperSizeofFilePath = bta.filePath;
        bta.SetFileName($"{xlsxScriptHelperClassName}_Select");
        xlsxScriptHelperSelectFilePath = bta.filePath;
    }
}

/// <summary>
/// Xlsx表自动生成目录架构_语言包子项
/// </summary>
[XmlRoot("ESF_Xml_XlsxAutoBuildFolder_LangItem")]
public class ESF_Xml_XlsxAutoBuildFolder_LangItem
{
    /// <summary>
    /// 语言类别
    /// </summary>
    [XmlElement("语言类别")]
    [ESF_NoDuplicateValue()]
    [ReadOnly()]
    public enESF_AllLanguageClassify classify;
    /// <summary>
    /// xlsx数据源表目录
    /// </summary>
    [XmlElement("xlsx数据源表目录")]
    [ESF_GUIBrower()]
    [ReadOnly()]
    public string xlsxTable_SrcFolder;
    /// <summary>
    /// db数据库表目标目录
    /// </summary>
    [XmlElement("db数据库表目标目录")]
    [ESF_GUIBrower()]
    [ReadOnly()]
    public string dbTable_TargetFolder;
}
#endif